from tonglun_py import *
import numpy as np
import psutil
import gc

export_fn("testpy", lambda x, y, z: x + y + z)

process = psutil.Process()
print('Initial memory:', process.memory_info().rss)

# Exact match to the original test
for i in range(10000):  # Smaller count for faster testing
    x = np.random.rand(100)
    call_fn("testpy", x, x.copy(), x.copy())
    if i % 1000 == 0:
        gc.collect()
        print(f"Iteration {i}, memory: {process.memory_info().rss}")

print('Final memory:', process.memory_info().rss) 